<template>
  <div class="home-page">
    <section class="py-5 text-center container">
      <div class="row py-lg-5">
        <div class="clo-lg-6 col-md-8 mx-auto">
          <img src="../assets/patterns.e8579768.png" alt="" class="w-50" />
          <h2>随心写作，自由表达</h2>
          <a href="#" class="btn btn-primary my-2">开始写文章</a>
        </div>
      </div>
    </section>
    <h4 class="font-weight-bold text-center">专栏·发现</h4>
    <ColumnList :list="list"></ColumnList>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent, onMounted } from "vue";
import { useStore } from "vuex"; //数据仓库 所有的东西都在这里面
import { GolbalDataProps } from "../store";
import ColumnList from "@/components/ColumnList.vue";

export default defineComponent({
  components: {
    ColumnList,
  },
  setup() {
    const store = useStore<GolbalDataProps>();
    const list = computed(() => store.state.colunms);
    // const biggerColumnLen = computed(() => {
    //   return store.state.colunms.filter((c) => c.id > 2).length;
    // });
    const biggerColumnLen = computed(() => store.getters.biggerColumnLen);
    // 组件挂载的时候调用
    onMounted(() => {
      store.dispatch("fetchColumns");
    });

    return {
      list: list,
      biggerColumnLen,
    };
  },
});
</script>

<style scoped></style>
